<?php


namespace app\lib\utils;


class StringUtils
{
    public static function hidePhoneNumber($phoneNumber) {
        $result = "";
        //判断手机号是否正确
        if(preg_match("/1\d{10}/", $phoneNumber)){
            //使用substr_replace将中间四位替换为*
            $result = substr_replace($phoneNumber, '****', 3, 4);
        }
        return $result;
    }
    public static function desensitizePhoneNumber($phone) {
        $desensitized = substr_replace($phone, '****', -4); // 将最后四位替换为 ****
        return $desensitized;
    }
}